#coding=utf-8
import sys,os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings')

import random
from datetime import *
from trp.models import *
from django.contrib.auth.models import *
from django.db import connection
import urllib

area_data = (
    ('北京市', '1156110000'),
    ('天津市', '1156120000'),
    ('河北省', '1156130000'),
    ('石家庄市', '1156130100'),
    ('唐山市', '1156130200'),
    ('秦皇岛市', '1156130300'),
    ('邯郸市', '1156130400'),
    ('邢台市', '1156130500'),
    ('保定市', '1156130600'),
    ('张家口市', '1156130700'),
    ('承德市', '1156130800'),
    ('沧州市', '1156130900'),
    ('廊坊市', '1156131000'),
    ('衡水市', '1156131100'),
    ('山西省', '1156140000'),
    ('太原市', '1156140100'),
    ('大同市', '1156140200'),
    ('阳泉市', '1156140300'),
    ('长治市', '1156140400'),
    ('晋城市', '1156140500'),
    ('朔州市', '1156140600'),
    ('晋中市', '1156140700'),
    ('运城市', '1156140800'),
    ('忻州市', '1156140900'),
    ('临汾市', '1156141000'),
    ('吕梁市', '1156141100'),
    ('内蒙古自治区', '1156150000'),
    ('呼和浩特市', '1156150100'),
    ('包头市', '1156150200'),
    ('乌海市', '1156150300'),
    ('赤峰市', '1156150400'),
    ('通辽市', '1156150500'),
    ('鄂尔多斯市', '1156150600'),
    ('呼伦贝尔市', '1156150700'),
    ('巴彦淖尔市', '1156150800'),
    ('乌兰察布市', '1156150900'),
    ('兴安盟', '1156152200'),
    ('锡林郭勒盟', '1156152500'),
    ('阿拉善盟', '1156152900'),
    ('辽宁省', '1156210000'),
    ('沈阳市', '1156210100'),
    ('大连市', '1156210200'),
    ('鞍山市', '1156210300'),
    ('抚顺市', '1156210400'),
    ('本溪市', '1156210500'),
    ('丹东市', '1156210600'),
    ('锦州市', '1156210700'),
    ('营口市', '1156210800'),
    ('阜新市', '1156210900'),
    ('辽阳市', '1156211000'),
    ('盘锦市', '1156211100'),
    ('铁岭市', '1156211200'),
    ('朝阳市', '1156211300'),
    ('葫芦岛市', '1156211400'),
    ('吉林省', '1156220000'),
    ('长春市', '1156220100'),
    ('吉林市', '1156220200'),
    ('四平市', '1156220300'),
    ('辽源市', '1156220400'),
    ('通化市', '1156220500'),
    ('白山市', '1156220600'),
    ('松原市', '1156220700'),
    ('白城市', '1156220800'),
    ('延边朝鲜族自治州', '1156222400'),
    ('黑龙江省', '1156230000'),
    ('哈尔滨市', '1156230100'),
    ('齐齐哈尔市', '1156230200'),
    ('鸡西市', '1156230300'),
    ('鹤岗市', '1156230400'),
    ('双鸭山市', '1156230500'),
    ('大庆市', '1156230600'),
    ('伊春市', '1156230700'),
    ('佳木斯市', '1156230800'),
    ('七台河市', '1156230900'),
    ('牡丹江市', '1156231000'),
    ('黑河市', '1156231100'),
    ('绥化市', '1156231200'),
    ('大兴安岭地区', '1156232700'),
    ('上海市', '1156310000'),
    ('江苏省', '1156320000'),
    ('南京市', '1156320100'),
    ('无锡市', '1156320200'),
    ('徐州市', '1156320300'),
    ('常州市', '1156320400'),
    ('苏州市', '1156320500'),
    ('南通市', '1156320600'),
    ('连云港市', '1156320700'),
    ('淮安市', '1156320800'),
    ('盐城市', '1156320900'),
    ('扬州市', '1156321000'),
    ('镇江市', '1156321100'),
    ('泰州市', '1156321200'),
    ('宿迁市', '1156321300'),
    ('浙江省', '1156330000'),
    ('杭州市', '1156330100'),
    ('宁波市', '1156330200'),
    ('温州市', '1156330300'),
    ('嘉兴市', '1156330400'),
    ('湖州市', '1156330500'),
    ('绍兴市', '1156330600'),
    ('金华市', '1156330700'),
    ('衢州市', '1156330800'),
    ('舟山市', '1156330900'),
    ('台州市', '1156331000'),
    ('丽水市', '1156331100'),
    ('安徽省', '1156340000'),
    ('合肥市', '1156340100'),
    ('芜湖市', '1156340200'),
    ('蚌埠市', '1156340300'),
    ('淮南市', '1156340400'),
    ('马鞍山市', '1156340500'),
    ('淮北市', '1156340600'),
    ('铜陵市', '1156340700'),
    ('安庆市', '1156340800'),
    ('黄山市', '1156341000'),
    ('滁州市', '1156341100'),
    ('阜阳市', '1156341200'),
    ('宿州市', '1156341300'),
    ('巢湖市', '1156341400'),
    ('六安市', '1156341500'),
    ('亳州市', '1156341600'),
    ('池州市', '1156341700'),
    ('宣城市', '1156341800'),
    ('湖北省', '1156420000'),
    ('武汉市', '1156420100'),
    ('黄石市', '1156420200'),
    ('十堰市', '1156420300'),
    ('宜昌市', '1156420500'),
    ('襄樊市', '1156420600'),
    ('鄂州市', '1156420700'),
    ('荆门市', '1156420800'),
    ('孝感市', '1156420900'),
    ('荆州市', '1156421000'),
    ('黄冈市', '1156421100'),
    ('咸宁市', '1156421200'),
    ('随州市', '1156421300'),
    ('恩施土家族苗族自治州', '1156422800'),
    ('湖南省', '1156430000'),
    ('长沙市', '1156430100'),
    ('株洲市', '1156430200'),
    ('湘潭市', '1156430300'),
    ('衡阳市', '1156430400'),
    ('邵阳市', '1156430500'),
    ('岳阳市', '1156430600'),
    ('常德市', '1156430700'),
    ('张家界市', '1156430800'),
    ('益阳市', '1156430900'),
    ('郴州市', '1156431000'),
    ('永州市', '1156431100'),
    ('怀化市', '1156431200'),
    ('娄底市', '1156431300'),
    ('湘西土家族苗族自治州', '1156433100'),
    ('四川省', '1156510000'),
    ('成都市', '1156510100'),
    ('自贡市', '1156510300'),
    ('攀枝花市', '1156510400'),
    ('泸州市', '1156510500'),
    ('德阳市', '1156510600'),
    ('绵阳市', '1156510700'),
    ('广元市', '1156510800'),
    ('遂宁市', '1156510900'),
    ('内江市', '1156511000'),
    ('乐山市', '1156511100'),
    ('南充市', '1156511300'),
    ('眉山市', '1156511400'),
    ('宜宾市', '1156511500'),
    ('广安市', '1156511600'),
    ('达州市', '1156511700'),
    ('雅安市', '1156511800'),
    ('巴中市', '1156511900'),
    ('资阳市', '1156512000'),
    ('阿坝藏族羌族自治州', '1156513200'),
    ('甘孜藏族自治州', '1156513300'),
    ('凉山彝族自治州', '1156513400'),
    ('贵州省', '1156520000'),
    ('贵阳市', '1156520100'),
    ('六盘水市', '1156520200'),
    ('遵义市', '1156520300'),
    ('安顺市', '1156520400'),
    ('铜仁地区', '1156522200'),
    ('黔西南布依族苗族自治州', '1156522300'),
    ('毕节地区', '1156522400'),
    ('黔东南苗族侗族自治州', '1156522600'),
    ('黔南布依族苗族自治州', '1156522700'),
    ('云南省', '1156530000'),
    ('昆明市', '1156530100'),
    ('曲靖市', '1156530300'),
    ('玉溪市', '1156530400'),
    ('保山市', '1156530500'),
    ('昭通市', '1156530600'),
    ('丽江市', '1156530700'),
    ('普洱市', '1156530800'),
    ('临沧市', '1156530900'),
    ('楚雄彝族自治州', '1156532300'),
    ('红河哈尼族彝族自治州', '1156532500'),
    ('文山壮族苗族自治州', '1156532600'),
    ('西双版纳傣族自治州', '1156532800'),
    ('大理白族自治州', '1156532900'),
    ('德宏傣族景颇族自治州', '1156533100'),
    ('怒江傈僳族自治州', '1156533300'),
    ('迪庆藏族自治州', '1156533400'),
    ('福建省', '1156350000'),
    ('福州市', '1156350100'),
    ('厦门市', '1156350200'),
    ('莆田市', '1156350300'),
    ('三明市', '1156350400'),
    ('泉州市', '1156350500'),
    ('漳州市', '1156350600'),
    ('南平市', '1156350700'),
    ('龙岩市', '1156350800'),
    ('宁德市', '1156350900'),
    ('江西省', '1156360000'),
    ('南昌市', '1156360100'),
    ('景德镇市', '1156360200'),
    ('萍乡市', '1156360300'),
    ('九江市', '1156360400'),
    ('新余市', '1156360500'),
    ('鹰潭市', '1156360600'),
    ('赣州市', '1156360700'),
    ('吉安市', '1156360800'),
    ('宜春市', '1156360900'),
    ('抚州市', '1156361000'),
    ('上饶市', '1156361100'),
    ('山东省', '1156370000'),
    ('济南市', '1156370100'),
    ('青岛市', '1156370200'),
    ('淄博市', '1156370300'),
    ('枣庄市', '1156370400'),
    ('东营市', '1156370500'),
    ('烟台市', '1156370600'),
    ('潍坊市', '1156370700'),
    ('济宁市', '1156370800'),
    ('泰安市', '1156370900'),
    ('威海市', '1156371000'),
    ('日照市', '1156371100'),
    ('莱芜市', '1156371200'),
    ('临沂市', '1156371300'),
    ('德州市', '1156371400'),
    ('聊城市', '1156371500'),
    ('滨州市', '1156371600'),
    ('菏泽市', '1156371700'),
    ('河南省', '1156410000'),
    ('郑州市', '1156410100'),
    ('开封市', '1156410200'),
    ('洛阳市', '1156410300'),
    ('平顶山市', '1156410400'),
    ('安阳市', '1156410500'),
    ('鹤壁市', '1156410600'),
    ('新乡市', '1156410700'),
    ('焦作市', '1156410800'),
    ('濮阳市', '1156410900'),
    ('许昌市', '1156411000'),
    ('漯河市', '1156411100'),
    ('三门峡市', '1156411200'),
    ('南阳市', '1156411300'),
    ('商丘市', '1156411400'),
    ('信阳市', '1156411500'),
    ('周口市', '1156411600'),
    ('驻马店市', '1156411700'),
    ('广东省', '1156440000'),
    ('广州市', '1156440100'),
    ('韶关市', '1156440200'),
    ('深圳市', '1156440300'),
    ('珠海市', '1156440400'),
    ('汕头市', '1156440500'),
    ('佛山市', '1156440600'),
    ('江门市', '1156440700'),
    ('湛江市', '1156440800'),
    ('茂名市', '1156440900'),
    ('肇庆市', '1156441200'),
    ('惠州市', '1156441300'),
    ('梅州市', '1156441400'),
    ('汕尾市', '1156441500'),
    ('河源市', '1156441600'),
    ('阳江市', '1156441700'),
    ('清远市', '1156441800'),
    ('东莞市', '1156441900'),
    ('中山市', '1156442000'),
    ('潮州市', '1156445100'),
    ('揭阳市', '1156445200'),
    ('云浮市', '1156445300'),
    ('广西壮族自治区', '1156450000'),
    ('南宁市', '1156450100'),
    ('柳州市', '1156450200'),
    ('桂林市', '1156450300'),
    ('梧州市', '1156450400'),
    ('北海市', '1156450500'),
    ('防城港市', '1156450600'),
    ('钦州市', '1156450700'),
    ('贵港市', '1156450800'),
    ('玉林市', '1156450900'),
    ('百色市', '1156451000'),
    ('贺州市', '1156451100'),
    ('河池市', '1156451200'),
    ('来宾市', '1156451300'),
    ('崇左市', '1156451400'),
    ('海南省', '1156460000'),
    ('海口市', '1156460100'),
    ('三亚市', '1156460200'),
    ('重庆市', '1156500000'),
    ('西藏自治区', '1156540000'),
    ('拉萨市', '1156540100'),
    ('昌都地区', '1156542100'),
    ('山南地区', '1156542200'),
    ('日喀则地区', '1156542300'),
    ('那曲地区', '1156542400'),
    ('阿里地区', '1156542500'),
    ('林芝地区', '1156542600'),
    ('陕西省', '1156610000'),
    ('西安市', '1156610100'),
    ('铜川市', '1156610200'),
    ('宝鸡市', '1156610300'),
    ('咸阳市', '1156610400'),
    ('渭南市', '1156610500'),
    ('延安市', '1156610600'),
    ('汉中市', '1156610700'),
    ('榆林市', '1156610800'),
    ('安康市', '1156610900'),
    ('商洛市', '1156611000'),
    ('甘肃省', '1156620000'),
    ('兰州市', '1156620100'),
    ('嘉峪关市', '1156620200'),
    ('金昌市', '1156620300'),
    ('白银市', '1156620400'),
    ('天水市', '1156620500'),
    ('武威市', '1156620600'),
    ('张掖市', '1156620700'),
    ('平凉市', '1156620800'),
    ('酒泉市', '1156620900'),
    ('庆阳市', '1156621000'),
    ('定西市', '1156621100'),
    ('陇南市', '1156621200'),
    ('临夏回族自治州', '1156622900'),
    ('甘南藏族自治州', '1156623000'),
    ('青海省', '1156630000'),
    ('西宁市', '1156630100'),
    ('海东地区', '1156632100'),
    ('海北藏族自治州', '1156632200'),
    ('黄南藏族自治州', '1156632300'),
    ('海南藏族自治州', '1156632500'),
    ('果洛藏族自治州', '1156632600'),
    ('玉树藏族自治州', '1156632700'),
    ('海西蒙古族藏族自治州', '1156632800'),
    ('宁夏回族自治区', '1156640000'),
    ('银川市', '1156640100'),
    ('石嘴山市', '1156640200'),
    ('吴忠市', '1156640300'),
    ('固原市', '1156640400'),
    ('中卫市', '1156640500'),
    ('新疆维吾尔自治区', '1156650000'),
    ('乌鲁木齐市', '1156650100'),
    ('克拉玛依市', '1156650200'),
    ('吐鲁番地区', '1156652100'),
    ('哈密地区', '1156652200'),
    ('昌吉回族自治州', '1156652300'),
    ('博尔塔拉蒙古自治州', '1156652700'),
    ('巴音郭楞蒙古自治州', '1156652800'),
    ('阿克苏地区', '1156652900'),
    ('克孜勒苏柯尔克孜自治州', '1156653000'),
    ('喀什地区', '1156653100'),
    ('和田地区', '1156653200'),
    ('伊犁哈萨克自治州', '1156654000'),
    ('塔城地区', '1156654200'),
    ('阿勒泰地区', '1156654300'),
    ('中国', '1156000000'),
    )

size_data = (
    (300, 100),
    (500, 200),
    (50, 300),
    (200, 100),
    (100, 600),
)

algorithm_data=(
    ('国美算法-根据网民浏览物料频次进行价格优化',
     '<line>\n'+ \
     '<text width="" align="left" bold="false">衰减系数</text>\n'+\
     '<textbox name="attenuation_coefficient" width="" type="string" default="">请输入...</textbox>\n'+\
     '<text width="" align="left" bold="false">初始价格</text>\n'+\
     '<textbox name="initial_price" width="" type="string" default="">请输入...</textbox>\n'+\
     '<text width="" align="left" bold="false">开始衰减的次数</text>\n'+\
      '<textbox name="attenuation_times" width="" type="string" default="">请输入...</textbox>\n'+\
      '</line>',
      'package com.semidata.trp.algorithm;\n'+\
       'import com.semidata.rtd.core.json.JsonObject;\n'+\
       'import com.semidata.rtd.core.json.JsonArray;\n'+\
       'import com.semidata.trp.algorithm.request.StrategyContext;\n'+\
       'import java.util.*;\n'+\
       'public class Algorithm {\n'+\
        'public static double calculate(StrategyContext context) {\n'+ \
        ' //此处添加算法代码，请不要修改框架代码\n'+\
        'double t = Double.parseDouble(context.getParams().getString("attenuation_coefficient"));\n'+\
        'double p = Double.parseDouble(context.getParams().getString("initial_price"));\n'+\
        'int m = Integer.parseInt(context.getParams().getString("attenuation_times"));\n'+\

        'List<String> mids = context.getMaterialsId();    //获取策略对应的物料id\n'+\
        'Map<String,Integer> materialFrequency = context.getMaterialFrequency();\n'+\

        'int sum = 0;\n'+\
        'for(String mid : mids) {\n'+\
        'Integer n = materialFrequency.get(mid);\n'+\
        'if(n!=null) {\n'+\
            'sum += n;\n'+\
        '}\n'+\
    '}\n'+\

    'if(sum<m) {\n'+\
        'return p;\n'+\
    '} else {\n'+\
        'return p / Math.pow(Math.E,sum * t);\n'+\
    '}\n'+\

  '}\n'+\
'}'),
   ('国美算法-预算优化',
    '<line>\n'+\
    '<text width="" align="left" bold="false">价格系数</text>\n'+\
    '<textbox name="price_coefficient" width="" type="string" default="">请输入...</textbox>\n'+\
    '<text width="" align="left" bold="false">价格上限</text>\n'+\
    '<textbox name="price_max" width="" type="string" default="">请输入...</textbox>\n'+\
    '</line>',
    'package com.semidata.trp.algorithm;\n'+\
'import com.semidata.rtd.core.json.JsonObject;\n'+\
'import com.semidata.rtd.core.json.JsonArray;\n'+\
'import com.semidata.trp.algorithm.request.StrategyContext;\n'+\
'import java.util.*;\n'+\
'public class Algorithm {\n'+\
  'public static double calculate(StrategyContext context) {\n'+\
    '//此处添加算法代码，请不要修改框架代码\n'+\
    'double t = Double.parseDouble(context.getParams().getString("price_coefficient"));\n'+\
    'double pMax = Double.parseDouble(context.getParams().getString("price_max"));\n'+\
    '//int margin = context.get总预算 - context.get总开销\n'+\
    'double margin = 0; // 当日余额\n'+\

    'int mediaType = context.getMediaType();\n'+\

    'if (mediaType == 0) {\n'+\
        'margin = context.getStrategyDailyInternalBudget() - context.getStrategyTodayInternalCost();\n'+\
 
    '} else if (mediaType == 1) {\n'+\
        'margin = context.getStrategyDailyExternalBudget() - context.getStrategyTodayExternalCost();\n'+\
    '} else if (mediaType == 2) {\n'+\
        'margin = context.getStrategyDailyAllyBudget() - context.getStrategyTodayAllyCost();\n'+\
    '} else {\n'+\
        'return 0;\n'+\
    '}\n'+\

    'int hour = 24 - context.getHour();\n'+\

    'double price = t * margin / hour;\n'+\

    'return Math.min(price, pMax);\n'+\

  '}\n'+\
'}'),
  ('国美算法-点击率优化',
   '<line>\n'+\
'<text width="" align="left" bold="false">价格系数</text>\n'+\
'<textbox name="price_coefficient" width="" type="string" default="">请输入...</textbox>\n'+\
'<text width="" align="left" bold="false">价格上限</text>\n'+\
  '<textbox name="price_max" width="" type="string" default="">请输入...</textbox>\n'+\
'</line>',
'package com.semidata.trp.algorithm;\n'+\
'import com.semidata.rtd.core.json.JsonObject;\n'+\
'import com.semidata.rtd.core.json.JsonArray;\n'+\
'import com.semidata.trp.algorithm.request.StrategyContext;\n'+\
'import java.util.*;\n'+\
'public class Algorithm {\n'+\
  'public static double calculate(StrategyContext context) {\n'+\
    '//此处添加算法代码，请不要修改框架代码\n'+\
    'double t = Double.parseDouble(context.getParams().getString("price_coefficient"));;\n'+\
    'double pMax = Double.parseDouble(context.getParams().getString("price_max"));\n'+\

    'Long clk = context.getResourceTodayClick();\n'+\
    ' Long imp = context.getResourceTodayImpression();\n'+\
    ' if(imp <= 0) {\n'+\
        'return 0;\n'+\
    '} \n'+\
     'double ctr = clk.doubleValue() / imp;\n'+\
     'double price = t * ctr;\n'+\
     'return Math.min(price, pMax);\n'+\
  '}\n'+\
'}'),                                 
)

def generate_relations(table, columns, values):
    strs = []
    for value in values:
        tmp = []
        for item in value:
            tmp.append('\'' + str(item) + '\'')
        strs.append('(%s)' % ','.join(tmp))
    sql = 'insert into %s (%s) values %s' % (table, ','.join(columns), ','.join(strs))
    cursor = connection.cursor()
    try:
        cursor.execute(sql)
    finally:
        cursor.close()

def generate_ids(objs):
    for id in range(0, len(objs)):
        objs[id].id = id + 1
    return objs


print 'start'

vendor_num = 100
merchant_num = 1000
media_num = 10
position_num = 10

data = {}
data['platform'] = {}
data['vendor'] = {}
data['merchant'] = {}

accounts = []
users = []
organizations = []
areas = []
material_types = []
material_tags = []
materials = []
media_attrs = []
media = []
position_attrs = []
positions = []
traffics = []
resources = []
allocations = []
strategies = []
algorithms=[]

def generate_areas():
    print 'generating areas'
    for item in area_data:
        area = Area(name=item[0], code=item[1])
        areas.append(area)
    Area.objects.bulk_create(generate_ids(areas))

def generate_organization(type, order):
    org = Organization()
    if type == 0:
        org.name = 'platform'
    elif type == 1:
        org.name = 'vendor %d' % order
        org.balance = random.uniform(500, 1000)
    else:
        org.name = 'merchant %d' % order
        org.balance = random.uniform(0, 300)
    org.description = ''
    org.contact = ''
    org.type = type
    return org


def generate_organizations():
    print 'generating organizations'
    org = generate_organization(0, 1)
    organizations.append(org)
    Organization.objects.bulk_create(generate_ids(organizations))

import time
def generate_user(type, order):
    user = User()
    if type == 0:
        user.username = 'gomeuser'
        user.last_name = 'gomeuser'
        user.email = 'gomeuser@gome.com.cn'
    elif type == 1:
        user.username = 'vendor%d' % order
        user.last_name = 'vendor%d user' % order
        user.email = 'user@vendor%d.com' % order
    else:
        user.username = 'merchant%d' % order
        user.last_name = 'merchant%d user' % order
        user.email = 'user@merchant%d.com' % order
    user.set_password(user.username)
    return user

def generate_users():
    print 'generating users'
    user = User()
    user.username = 'admin'
    user.last_name = 'admin'
    user.email = 'admin@gome.com.cn'
    user.set_password("gometrp_001!@#$")
    users.append(user)
    User.objects.bulk_create(generate_ids(users))

def generate_account(user):
    account = Account()
    account.user = user
    account.phone = ''
    account.description = ''
    return account

def generate_accounts():
    print 'generating accounts'
    relations = []

    account = Account()
    account.user = users[0]
    account.phone = ''
    account.description = ''
    account.admin = True
    account.id = 1
    accounts.append(account)
    relations.append((account.id, 1))
    Account.objects.bulk_create(accounts)
    generate_relations('trp_account_organization', ('account_id', 'organization_id'), relations)

def generate_material_types():
    print 'generating material types'
    material_types.append(MaterialType(name='PNG', id = 1))
    material_types.append(MaterialType(name='JPG', id = 2))
    material_types.append(MaterialType(name='GIF', id = 3))
    material_types.append(MaterialType(name='BMP', id = 4))
    material_types.append(MaterialType(name='SWF', id = 5))
    MaterialType.objects.bulk_create(material_types)

def generate_algorithms():
    print 'generating algorithms'
    for item in algorithm_data:
        algorithm = Algorithm(name= item[0], xml_format= urllib.quote(item[1]),code= item[2],status=1,passed=True)
        algorithms.append(algorithm)
    Algorithm.objects.bulk_create(generate_ids(algorithms))

starttime = time.time()
def set_time(time):
    starttime = time
def print_time_cost():
    current = time.time()
    print 'time cost = %f' % (current - starttime)
    set_time(current)


generate_areas()
print_time_cost()
generate_organizations()
print_time_cost()
generate_users()
print_time_cost()
generate_accounts()
print_time_cost()
generate_material_types()
print_time_cost()
generate_algorithms()
print_time_cost()


